<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>非受控组件</title>
    <style>

    </style>
</head>
<body>
<!--准备好一个容器-->
<div id="root"></div>

<!--引入React核心库-->
<script type="text/javascript" src="../0-ReactJs-v16.14.0/react.development.js"></script>
<!--引入React-Dom，用于支持React操作Dom-->
<script type="text/javascript" src="../0-ReactJs-v16.14.0/react-dom.development.js"></script>
<!--引入babel，用于将jsx转为js-->
<script type="text/javascript" src="../0-ReactJs-v16.14.0/babel.min.js"></script>

<script type="text/babel">

    //创建组件
    class Login extends React.Component {

        handleSubmit = (event) => {
            event.preventDefault()//阻止表单提交
            const {userName,passWord} = this
            alert(`你输入的用户名是${userName.value}，你输入的密码是${passWord.value}`)
        }

        render() {
            return (
                <form onSubmit={this.handleSubmit}>
                    用户名：<input ref={c=>this.userName = c} onChange={this.saveUserName} type="text" name="userName"/>
                    密码：<input ref={c=>this.passWord = c} onChange={this.savePassWord} type="password" name="passWord"/>
                    <button>登陆</button>
                </form>
            )
        }
    }

    //渲染组件到页面
    ReactDOM.render(<Login/>, document.getElementById('root'));

</script>

</body>
</html>
